
import {Controller, ControllerBind} from "../../../src/core/Controller";

import {ActionBind} from "../../../src/core/Action";

import {ParaTypes, PType} from "../../../src/extra/params/EasyAParaTypes";
import {ValidateParam} from "../../../src/extra/params/ParaValidateInterceptor";
import {Ctx} from "../../../src";
import {FileUpload} from "../../../src/extra/interceptors/FileUpload";
import {intercept} from "../../../src/core/Interceptor";


@ControllerBind({
    routePath:'/'
})
export class RootController extends Controller{

    @ActionBind({route:'/'})
    @ValidateParam({
        id:PType.int({
            b:(self,ctx)=>{
                self.errMsg = ctx.i18t('errMsg1');
            }
        }),
        p:PType.int({
            default:1
        })
    })
    index(ctx:Ctx){

        const {id, p} = ctx.validatedParams;

        ctx.mm.国际化 = ctx.i18t('key1');

        ctx.mm.页数 = p;
        ctx.setcm(0,'这是主页面');
        ctx.next();
    }

    @intercept(FileUpload.create({fieldName:'myFile',}))
    async avatar(ctx:Ctx){

        var xx = undefined
        const {file} = ctx.params;
        console.log(file);
        ctx.next();
    }



}
